package br.facet.bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import br.facet.dao.ClienteDAO;
import br.facet.dao.VendaDAO;
import br.facet.pojo.Venda;

@ManagedBean (name = "VendaBean")
@RequestScoped
public class VendaBean {
	
	ClienteDAO clienteDao = new ClienteDAO();
	VendaDAO vendaDao = new VendaDAO();
	
	private Integer idCliente;
	
	public String finalizarVenda() throws Exception{
		Venda venda = new Venda();		
		venda.setCliente(clienteDao.load(this.idCliente));
		vendaDao.salvar(venda);		
		return "index";
	}
	
	
	public Integer getIdCliente() {
		return idCliente;
	}

	public void setIdCliente(Integer idCliente) {
		this.idCliente = idCliente;
	}
}
